package com.example.user.domain.course;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.common.core.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@TableName("tb_course")
@Getter
@Setter
@ToString
public class Course extends BaseEntity {

    // 课程状态常量
    public static final int STATUS_CREATED = 0;     // 已创建
    public static final int STATUS_RECORDING = 1;   // 录制中
    public static final int STATUS_REVIEWING = 2;   // 待审核
    public static final int STATUS_PUBLISHED = 3;   // 已发布
    public static final int STATUS_REJECTED = 4;    // 驳回

    @TableId(type = IdType.ASSIGN_ID)
    private Long courseId;

    @Schema(name = "课程名称")
    private String courseName;

    @Schema(name = "教师Id")
    private Long teacherId;

    @Schema(name = "班级Id")
    private Long classroomId; // 精品课程是独立的，班级中也有课程

    @Schema(name = "教师名称")
    private String teacherName;

    @Schema(name = "视频数量")
    private Integer videoNum = 0;
    
    @Schema(name = "课程状态: 0-已创建,1-录制中,2-待审核,3-已发布,4-驳回")
    private Integer status = STATUS_CREATED;

    public void addVideo() {
        if (videoNum == null) {
            videoNum = 0;
        }
        videoNum++;
    }

    public void deleteVideo() {
        if (videoNum == null || videoNum <= 0) {
            videoNum = 0;
            return;
        }
        videoNum--;
    }
}